/**
 * @description reducers
 */

// import { userType } from "@/types"
interface userType {
  uid?: string | number
  username?: string
  password?: string
  role?: number
  roleState?: boolean
  region?: string
  joinDate?: string
}

const initState: userType = {}

export default function userReducer(previousState: userType = initState, action: { type: string; data: userType }) {
  const { type, data } = action
  switch (type) {
    case "set":
      return { ...data }
    case "update":
      return { ...previousState, ...data }
    case "delete":
      return {}
    default:
      return initState
  }
}
